package com.qmds.common.baidu.config;


import com.baidu.aip.contentcensor.AipContentCensor;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;



/**
 * --- 天道酬勤 ---
 *
 * @author zhanghanxuan
 * @date 2024/8/26
 * @desc
 */
@Component
@EnableConfigurationProperties(BaiduProperties.class)
public class BaiduConfig {

    @Resource
    private BaiduProperties baiduProperties;


    // 创建百度文本审核工具类
    @Bean
    public AipContentCensor getAipContentCensor() {
      AipContentCensor  client = new AipContentCensor(baiduProperties.getAPP_ID(), baiduProperties.getAPI_KEY(), baiduProperties.getSECRET_KEY());
        // 可选：设置网络连接参数
        client.setConnectionTimeoutInMillis(2000);
        client.setSocketTimeoutInMillis(60000);
        return client;
    }
}
